import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:jinke/page/report/model/ReportEntity.dart';
import 'package:jinke/utils/util.dart';

import '../widgets/item_report_detail.dart';
import 'logic.dart';
import 'view_edit.dart';

class ReportDetailPage extends StatelessWidget {
  final logic = Get.put(ReportDetailLogic());
  final state = Get.find<ReportDetailLogic>().state;

  @override
  Widget build(BuildContext context) {
    ReportEntity entity = Get.arguments;
    return Scaffold(
      backgroundColor: const Color(0xFFF1F2F7),
      body: GetBuilder<ReportDetailLogic>(
        builder: (_){
          return Column(
            children: [
              Expanded(child: Stack(
                children: [
                  SingleChildScrollView(
                    child: Stack(
                      children: [
                        Image.asset('bg_ribaoxiangqing.png'.imgPathReport,width: 1.sw,height: 260.r,fit: BoxFit.cover,),
                        Padding(
                          padding: EdgeInsets.only(left: 20.r,right: 20.r),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              SizedBox(height: 90.r,),
                              Text('金水科教园招商引资项\n目推进工作日报',style: TextStyle(color: Colors.white,fontWeight: FontWeight.w800,fontSize: 20.r),),

                              Container(
                                width: 100.r,
                                height: 25.r,
                                margin: EdgeInsets.only(top: 16.r,bottom: 20.r),
                                decoration: BoxDecoration(
                                    color: const Color.fromARGB(100, 82, 176, 255),
                                    borderRadius: BorderRadius.circular(12.r),
                                    border: Border.all(color: Color(0xFFB7DEFF,),width: 1.r)
                                ),
                                child: Center(child: Text(entity.reportDate??'',style: TextStyle(color: Colors.white,fontSize: 13.r),),),
                              ),
                              Container(
                                width: 1.sw,
                                margin: EdgeInsets.only(bottom: 20.r),
                                padding: EdgeInsets.all(15.r),
                                decoration: BoxDecoration(
                                    boxShadow: [
                                      BoxShadow(
                                          offset: const Offset(1, 1),//x,y轴
                                          color: const Color(0x1A071428),//投影颜色
                                          blurRadius: 2.r//投影距离
                                      )
                                    ],
                                    borderRadius: BorderRadius.circular(4.r),
                                    color: Colors.white
                                ),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Row(
                                      children: [
                                        Text('总体总结',style: TextStyle(color: Color(0xff333333),fontSize: 16.r,fontWeight: FontWeight.bold),),
                                        SizedBox(width: 5.r,),
                                        Text('(截至今日)',style: TextStyle(color: Color(0xFF0086F6),fontSize: 14.r,fontWeight: FontWeight.w500),),
                                      ],
                                    ),
                                    Container(
                                      decoration: BoxDecoration(
                                          borderRadius: BorderRadius.circular(4.r),
                                          color: Color(0xFFF1F2F7)
                                      ),
                                      padding: EdgeInsets.fromLTRB(10.r,15.r,10.r,15.r),
                                      margin: EdgeInsets.only(top: 15.r),
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                                        children: [
                                          Column(
                                            children: [
                                              Text(state.totleInsert.toString(),style: TextStyle(color: Color(0xff333333),fontSize: 20.r,fontWeight: FontWeight.bold),),
                                              Text('共计入库(个)',style: TextStyle(color: Color(0xff666666),fontSize: 12.r,fontWeight: FontWeight.w500),),
                                            ],
                                          ),
                                          Container(color: Color(0xFFCCCFE1),width: 1.r,height: 23.r,),
                                          Column(
                                            children: [
                                              Text(state.newInsert.toString(),style: TextStyle(color: Color(0xff333333),fontSize: 20.r,fontWeight: FontWeight.bold),),
                                              Text('今日新增(个)',style: TextStyle(color: Color(0xff666666),fontSize: 12.r,fontWeight: FontWeight.w500),),
                                            ],
                                          ),
                                          Container(color: Color(0xFFCCCFE1),width: 1.r,height: 23.r,),
                                          Column(
                                            children: [
                                              Text(state.statusZb.toString(),style: TextStyle(color: Color(0xff333333),fontSize: 20.r,fontWeight: FontWeight.bold),),
                                              Text('项目新进展(个)',style: TextStyle(color: const Color(0xff666666),fontSize: 12.r,fontWeight: FontWeight.w500),),
                                            ],
                                          ),
                                        ],
                                      ),
                                    )
                                  ],
                                ),
                              ),
                              Text('进展明细',style: TextStyle(color: const Color(0xff333333),fontSize: 16.r,fontWeight: FontWeight.bold),),
                              SizedBox(height: 16.r,),
                              ListView.builder(itemBuilder: (context,index){
                                return ItmeReportDetail(state.detailentityList[index]);
                              },itemCount: state.detailentityList.length,physics: const NeverScrollableScrollPhysics(),shrinkWrap: true,padding: EdgeInsets.zero,)
                            ],
                          ),
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: 150.r,
                    child: SafeArea(child: AppBar(
                      leading: BackButton(color: Colors.white,onPressed: (){
                        Get.back(result: state.entity.isRead);
                      },),
                      centerTitle: true,
                      backgroundColor: Colors.transparent,
                      elevation: 0,
                      title: Text('日报详情',style: TextStyle(color: Colors.white,fontSize: 17.r,fontWeight: FontWeight.bold),),
                    )),
                  ),
                ],
              )),
              Row(
                children: [
                  Expanded(child: GestureDetector(
                    onTap: (){

                      Get.to(Report_editPage())!.then((value) {
                        if(value==true){
                          logic.getReportDetail();
                        }
                      });
                    },
                    child: Container(
                      height: 55.r,
                      color: Colors.white,
                      child: Center(child: Text('编辑',style: TextStyle(color: Color(0xff333333),fontSize: 15.r,fontWeight: FontWeight.w500),),),
                    ),
                  )),
                  Expanded(child: GestureDetector(
                    onTap: (){
                      logic.getDownLoadUrl(false);
                    },
                    child: Container(
                      height: 55.r,
                      margin: EdgeInsets.only(left: 0.5,right: 0.5),
                      color: Colors.white,
                      child: Center(child: Text('下载',style: TextStyle(color: Color(0xff333333),fontSize: 15.r,fontWeight: FontWeight.w500),),),
                    ),
                  )),
                  Expanded(child: GestureDetector(
                    onTap: (){
                      logic.getDownLoadUrl(true);
                    },
                    child: Container(
                      height: 55.r,
                      decoration: BoxDecoration(
                        gradient: const LinearGradient(      //渐变位置
                            begin: Alignment.centerLeft, //右上
                            end: Alignment.centerRight, //左下
                            stops: [0.0, 1.0],         //[渐变起始点, 渐变结束点]
                            //渐变颜色[始点颜色, 结束颜色]
                            colors: [Color(0xff00A9FE), Color(0xFF0173FE)]
                        ),
                        color: Colors.white,
                      ),

                      child: Center(child: Text('分享',style: TextStyle(color: Colors.white,fontSize: 15.r,fontWeight: FontWeight.w500),),),
                    ),
                  )),
                ],
              )
            ],
          );
        },
      )
    );
  }
}
